import 'package:flutter/material.dart';
import 'package:provider/provider.dart';

import '../manager/item_detail_data_manager.dart';
import '../model/item_detail_do.dart';

class UserTitle extends StatefulWidget {
  const UserTitle({Key? key}) : super(key: key);

  @override
  State<UserTitle> createState() => _UserTitleState();
}

class _UserTitleState extends State<UserTitle> {
  @override
  Widget build(BuildContext context) {
    final ItemDetailDataManager itemDetailDataManager = Provider.of<ItemDetailDataManager>(context);
    return Container(
        height: 64,
        padding: const EdgeInsets.fromLTRB(16.0, 0, 16.0, 0),
        color: Colors.white,
        child: Row(
          crossAxisAlignment: CrossAxisAlignment.center,
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            Container(
              margin: const EdgeInsets.only(right: 8.0),
              child: ClipRRect(
                borderRadius: const BorderRadius.all(Radius.circular(20.0)),
                child: Image.network(
                  itemDetailDataManager.itemDetailDO.avatarUrl,
                  width: 40.0,
                  height: 40.0,
                ),
              ),
            ),
            Expanded(
              child: Column(
                crossAxisAlignment: CrossAxisAlignment.start,
                mainAxisAlignment: MainAxisAlignment.center,
                children: <Widget>[
                  Text(itemDetailDataManager.itemDetailDO.nick,
                    style: const TextStyle(fontSize: 14.0, color: Color(0xFF333333), fontWeight: FontWeight.bold),
                    maxLines: 1,
                  ),
                  Text(itemDetailDataManager.itemDetailDO.userInfo,
                    style: const TextStyle(fontSize: 12.0, color: Color(0xFFA3A3A3), fontWeight: FontWeight.bold),
                    maxLines: 1,
                  ),
                ],
              ),
            ),
            GestureDetector(
              child: Container(
                alignment: Alignment.center,
                margin: const EdgeInsets.only(left: 8.0),
                child: Image.asset(
                  itemDetailDataManager.attention ? 'assets/images/un_attention.png' : 'assets/images/attention.png',
                  width: 64.0,
                  height: 32.0,
                ),
              ),
              onTap: () {
                setState(() {
                  itemDetailDataManager.attention = !itemDetailDataManager.attention;
                });

              },

            ),
          ],
        ));
  }
}